//函数式实现条件渲染
import { Component, useState } from "react";
function DemoA() {
    let [num, SetNum] = useState(0)

    let renderHn = () => {
        let res = null;
        switch (num) {
            case 0:
                res = <h1>我是h1</h1>
                break;
            case 1:
                res = <h1>我是h2</h1>
                break;
            case 2:
                res = <h1>我是h3</h1>
                break;
        }
        return res
    }
    return (
        <div>
            {renderHn()}
            {/* <h1> 我是打标签</h1> */}
            <button onClick={() => SetNum((num + 1) % 3)} >点击改变num</button>
        </div>
    )
}

export default DemoA;
